<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" template="/template/template.xhtml"
	xmlns:s="http://sduept.security.el/func">
	<ui:define name="head">
		<title>录波文件列表</title>
		<link rel="stylesheet" href="/resources/plugins/datatables/dataTables.bootstrap.css" />
		<style>
iframe {
width: 100%; height: 600px;
}

.ui-datalist-empty-message {
/* height: 100px; */
min-height: 100px;
}

.ui-datalist-content {
/* height: 100px; */
min-height: 100px;
}

.yes {
color: red;
}

.no {
color: green;
}
</style>
	</ui:define>
	<ui:define name="content">
		<div class='full-center-content-scroll-noheader'>
			<div class="chart tab-pane active" id="statistics" style="position: relative">
				<p:growl id="msgs" showDetail="true" />
				<div id="InterruptAlarm" class="chart tab-pane active">
					<h:form id="form1">
						<div class="box box-primary box-solid with-border">
							<div class="box-header">
								<h3 class="box-title">指定时间查询</h3>
								<div class="box-tools pull-right">
									<button class="btn btn-default btn-sm" data-widget="collapse">
										<i class="fa fa-minus"></i>
									</button>
								</div>
							</div>
							<div class="box-body">
								<p:outputLabel for="popup1" value="时间间隔：" style="float:left;margin-top:5px" />
								<p:calendar id="popup1" navigator="true" value="#{waveFileInfoController.start}"
									pattern="yyyy-MM-dd HH:mm:ss" style="float:left">
								</p:calendar>
								<p:outputLabel for="popup2" value="至"
									style="margin-right:5px;margin-left:5px;float:left;margin-top:5px" />
								<p:calendar id="popup2" navigator="true" value="#{waveFileInfoController.end}"
									pattern="yyyy-MM-dd HH:mm:ss" style="float:left">
								</p:calendar>
								<p:outputLabel value="选择设备：" style="margin-left:8px" />
								<p:inputText id="equipment" readonly="true"
									onfocus="document.getElementById('form1:selEquBtn').click();"
									value="#{waveFileInfoController.chooseobjectName}" />
								<p:commandButton value="选择设备" process="@this" id="selEquBtn"
									style="visibility:hidden ;width:0px;height:0px;margin-left:5px;"
									actionListener="#{waveFileInfoController.openSelectEquipmentDialog()}">
									<p:ajax event="dialogReturn" listener="#{waveFileInfoController.onObjectSelectorChosen}"
										update="form1:equipment" />
								</p:commandButton>
								<p:commandButton icon="ui-icon-search" value="查询" update="form1:waveInfoList"
									actionListener="#{waveFileInfoController.queryAction}" style="margin-left:10px;">
								</p:commandButton>
								<p:commandButton icon="ui-icon-refresh" value="重置"
									update="form1:equipment form1:waveInfoList"
									actionListener="#{waveFileInfoController.clearObjectSelectorChosen}"
									style="margin-left:10px;">
								</p:commandButton>
							</div>
						</div>
						<p:dataTable id="waveInfoList" var="item" value="#{waveFileInfoController.waveFileList}"
							rowKey="#{item.id}" emptyMessage="无记录" rowIndexVar="ite" rows="20" paginator="true"
							paginatorPosition="bottom"
							paginatorTemplate="{Customization} {FirstPageLink} 
								{PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
							rowsPerPageTemplate="20,50,100">
							<f:facet name="{Customization}">
								<p:outputLabel value="总计：#{waveFileInfoController.waveFileList.size()} 条记录"
									style="margin-right:20px;"></p:outputLabel>
							</f:facet>
							<p:column headerText="序号 " style="width:10px;text-align:center">
								<h:outputText value="#{ite+1}" />
							</p:column>
							<p:column width="20" headerText="时间">
								<h:outputText value="#{item.triggerSecond.substring(0,19)}">
								</h:outputText>
							</p:column>
							<p:column width="20" headerText="变电站名称">
								<h:outputText value="#{item.stationName}" />
							</p:column>
							<p:column width="50" headerText="装置">
								<h:outputText value="#{item.equipment}" />
							</p:column>
							<p:column width="50" headerText="录波文件">
								<p:commandLink actionListener="#{waveFileInfoController.prepareOpenWaveView(item)}"
									style="text-decoration:underline;color:red;" oncomplete="openWaveDlg()" target="_blank"
									update="form1:type form1:fileId" value="#{item.path}" />
							</p:column>
							<p:column width="8" headerText="分析状态">
								<h:outputText value="#{item.status}" />
							</p:column>
							<p:column width="4" headerText="操作" style="text-align:center;">
								<p:commandLink ajax="false" value="下载" style="text-decoration:underline;color:red;"
									rendered="#{s:hasPermission(session,'jcsj_lbwjck_cz_xz')}"
									actionListener="#{waveFileInfoController.prepareDownload(item)}">
									<p:fileDownload value="#{waveFileInfoController.file}"></p:fileDownload>
								</p:commandLink>
							</p:column>
						</p:dataTable>
						<h:inputHidden id="type" value="#{waveFileInfoController.type}" />
						<h:inputHidden id="fileId" value="#{waveFileInfoController.fileId}" />
					</h:form>
				</div>
			</div>
		</div>
		<script>
			function openWaveDlg() {
				var type = document.getElementById("form1:type").value;
				var fileId = document.getElementById("form1:fileId").value;
				var url = "/ui/waveh5/index.html?fileId=" + fileId + "&amp;type=" + type;
				MyModal.showModal(url);
			}
		</script>
		<script>
			function onSelectDivClick() {
				var div = $('#selectDiv');
				if (div.hasClass('in')) {
					div.collapse('hide');
					$('#selectButtonIcon').removeClass("fa fa-caret-up");
					$('#selectButtonIcon').addClass("fa fa-caret-down");
				} else {
					div.collapse('show');
					$('#selectButtonIcon').removeClass("fa fa-caret-down");
					$('#selectButtonIcon').addClass("fa fa-caret-up");
				}
			}
		</script>
	</ui:define>
</ui:composition>
